home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ADA Programming Guide
/
ADA Programming Guide.iso
/
adatutor
/
cppwkbk
/
cppv1-4.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-30
|
645b
|
40 lines
#define HEADER "C++ Problem 1.4 by Rick Conn using Borland C++"
#include <stdio.h>
class counter {
int count;
public:
void set(int);
void increment(void);
void display(void);
};
void counter::set (int new_value) {
count = new_value;
}
void counter::increment (void) {
count++;
}
void counter::display (void) {
printf("The count of the object at address %p is %d\n",
this, count);
}
void main(void)
{
printf("%s\n", HEADER);
counter c1, c2;
c1.set (5);
c2.set (-12);
c1.display();
c2.display();
c1.increment();
c2.increment();
c1.display();
c2.display();
}